<?php

class AiTools
{
  protected $names = array('Erik', 'Leonidas', 'Cesar', 'Xerxes');
  protected $used_names = array();

  protected $city_names = array('Persepolis', 'Athena', 'Alexandria', 'Capua', 'Carthage');
  protected $used_city_names = array();

  public function getRandomName()
  {
    $rand = rand(0, count($this->names)-1);
    while (in_array($this->names[$rand], $this->used_names))
    {
      $rand = rand(0, count($this->names)-1);
    }
    $this->used_names[] = $this->names[$rand];
    return $this->names[$rand];
  }

  public function getRandomCityName()
  {
    $rand = rand(0, count($this->city_names)-1);
    while (in_array($this->city_names[$rand], $this->used_city_names))
    {
      $rand = rand(0, count($this->city_names)-1);
    }
    $this->used_city_names[] = $this->city_names[$rand];
    return $this->city_names[$rand];
  }
}